#include<stdio.h>
#include<mpi.h>

int main(int argc, char **argv)
{
	int myid, numprocs, new_numprocs;
	MPI_Group group_world, odd_group;
	MPI_Comm new_comm;
	int i;
	int members[10];
		
	MPI_Init(&argc, &argv);
	
	MPI_Comm_rank(MPI_COMM_WORLD, &myid);
    MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
	
	MPI_Comm_group(MPI_COMM_WORLD, &group_world);

	for(i=0; i<numprocs/2; i++) {
		members[i] = 2*i+1 ;
	}
	
	MPI_Group_incl(group_world, numprocs/2, members, &odd_group);
	
	// your code here
    //用由group所定义的通信组及一个新的上下文创建了一个新的通信子newcomm。
    //对于不在group中的进程，函数返回MPI_COMM_NULL。
	MPI_Comm_create(MPI_COMM_WORLD, odd_group, &new_comm);
	// end of your code
	
	if (myid % 2 != 0 ) {
	    MPI_Comm_size(new_comm, &new_numprocs);
	    
		printf("The new comm's size is %d.\n", new_numprocs);
	} 
	

	MPI_Finalize();
	return 0;
} 
